﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.OrdesModel;
using TodoApp.TodoStatusDTO;
using Volo.Abp.Domain.Repositories;

namespace TodoApp
{
    /// <summary>
    ///  订单 状态 实现 服务接口 
    /// </summary>
    public class StatusService : Volo.Abp.Application.Services.ApplicationService, IStatusService
    {

        private readonly IRepository<TodoStatus, int> _todoStatuses;
        public StatusService(IRepository<TodoStatus, int> db ) {
            _todoStatuses = db;
        }

        public async Task DeletAsync( int id )
        {
            await _todoStatuses.DeleteAsync(id);
        }

        public async Task<List<TodoStatusShowDTO>> GetListAsync()
        {
           return  ObjectMapper.Map<List<TodoStatus>, List<TodoStatusShowDTO>>(await _todoStatuses.GetListAsync());
        }

        public async Task<string> InsertAsync(TodoStatusAddDTO model)
        {
             await _todoStatuses.InsertAsync(ObjectMapper.Map<TodoStatusAddDTO, TodoStatus>(model));

            return "添加成功";
        }
    }
}
